#include "stdafx.h"
#include "GlobalConfigDef.h"
#include "InstanceTouch.h"
DECL_INSTANCE_TOUCH(ETouch_GlobalConfigDef);

struct  GlobalConfigDefDefReflectionRegister
{
	GlobalConfigDefDefReflectionRegister()
	{
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iID,INVALID_ID).Editor_SetAsPrimaryKey();
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_sDisplayName,std::string("DefaultName")).Editor_SetAsDisplayName();
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_bActive,true).Editor_SetAsRaw();


		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iDealCardNumOnFirstRound,1).Editor_SetAsRaw("Combat");
		
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_i2MapStarBonusMulti,2.f).Editor_SetAsRaw("MapBonus");
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_i3MapStarBonusMulti,3.f).Editor_SetAsRaw("MapBonus");

		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_sCombatEmulatorExePath,std::string("../../CombatEmulator")).Editor_SetAsRaw("CombatEmulator");
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_sCombatEmulatorExeName,std::string("magiccarddeluxe_test.exe")).Editor_SetAsRaw("CombatEmulator");
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_sCombatEmulatorDataFullFilePath,std::string("../../CombatEmulator/EmulatorCombat/combat.txt")).Editor_SetAsRaw("CombatEmulator");
		
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iDailyQuestRatingLevelLimit,10).Editor_SetAsRaw("DailyQuest");

		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iLogoutKickTime,30).Editor_SetAsRaw("GameServer");

		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iFriendGiftAddEnergy,2).Editor_SetAsRaw("Friend");

		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iNewbieGiftDropID,INVALID_ID).Editor_SetAsRaw("Newbie");

		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iRevengeCost,3).Editor_SetAsRaw("Revenge");
		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iFreeRevengePerDay,1).Editor_SetAsRaw("Revenge");

		REGISTER_REFLECTION_MEMBER(GlobalConfigDef,m_iCombatLogThreshold,300).Editor_SetAsRaw("system");


		GlobalClassManager::Instance().RegisterClass(GlobalConfigDef::s_GetReflection(),eDefaultDef_GlobalConfigDef);
		GlobalDefManager::Instance().RegisterDefManger(&GlobalConfigDefManager::Instance());

	}
}___GlobalConfigDefDefReflectionRegister;

rewrite  void GlobalConfigDef::OnArchieveReaded()
{
}

void GlobalConfigDefManager::OnArchieveReaded()
{
	__GlobalConfigDefManager::OnArchieveReaded();

	m_pConfig=NULL;
	std::vector<const GlobalConfigDef*> vItems;
	this->Enumerate(vItems);
	for(uint32 ii=0;ii<vItems.size();ii++)
	{
		if(vItems[ii]->m_bActive)
		{
			m_pConfig=vItems[ii];
			break;
		}
	}
	if(NULL==m_pConfig)
	{
		printf("No Active GlobalConfigDef Exists!\n");
		m_pConfig= &DefaultStaticItem();

	}
}